<?php

namespace App\Trip\Auth\Providers;

use App\Models\User\User;
use Illuminate\Auth\EloquentUserProvider;
use Illuminate\Contracts\Hashing\Hasher as HasherContract;
use Illuminate\Support\Facades\Cache;

class CacheModelUserProvider extends EloquentUserProvider
{
    public function __construct(HasherContract $hasher, $model) { parent::__construct($hasher, $model); }

    public function retrieveById($identifier)
    {
        $cache_key = User::cacheKey($identifier);
        return Cache::get($cache_key) ?: parent::retrieveById($identifier);
    }

}